# -*- coding:utf-8 -*-
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from .topPanel import topPanel
from com.mat.rpa.views.workWindow.leftPanel import leftPanel
from com.mat.rpa.views.workWindow.middlePanel import middlePanel
from com.mat.rpa.views.workWindow.rightPanel import righPanel
class WorkMainWindow(QMainWindow):
    def __init__(self, parent=None):
        super(WorkMainWindow, self).__init__(parent)
        #添加图标和标题
        self.setWindowIcon(QIcon('./com/mat/rpa/views/images/logo.ico'))
        self.setWindowTitle("未命名应用")
        self.parentPanel = parent
        self.centralwidget = QWidget(self)
        self.centralwidget.setObjectName("centralwidget")
        self.horizontalLayout = QHBoxLayout(self.centralwidget)
        self.horizontalLayout.setContentsMargins(5,0,5,5)
        self.horizontalLayout.setSpacing(0)
        self.horizontalLayout.setObjectName("horizontalLayout")
        self.centralwidget.setLayout(self.horizontalLayout)
        self.setCentralWidget(self.centralwidget)
        # 添加顶部工具菜单栏
        self.topBar = topPanel.TopBar(self)
        self.addToolBar(self.topBar)
        #创建左中分割条
        self.leftCenterSplitter = QSplitter(self.centralwidget)
        self.horizontalLayout.addWidget(self.leftCenterSplitter)
        self.leftCenterSplitter.setOrientation(Qt.Horizontal)
        self.leftCenterSplitter.setChildrenCollapsible(False)
        self.leftCenterSplitter.setObjectName("leftCenterSplitter")
        self.leftPanel = leftPanel.LeftPanel(self)
        self.leftCenterSplitter.addWidget(self.leftPanel)
        #创建中右分割条
        self.centerRightSplitter = QSplitter(self.leftCenterSplitter)
        self.leftCenterSplitter.addWidget(self.centerRightSplitter)
        self.centerRightSplitter.setMinimumSize(QSize(200, 0))
        self.centerRightSplitter.setOrientation(Qt.Horizontal)
        self.centerRightSplitter.setChildrenCollapsible(False)
        self.centerRightSplitter.setObjectName("centerRightSplitter")
        #添加中间工作面板
        self.middleWorkPanel = middlePanel.MiddlePanel(self)
        self.centerRightSplitter.addWidget(self.middleWorkPanel)
        self.middleWorkPanel.getMainWindow(self)
        #添加右边面板
        self.rightPanel = righPanel.RightPanel(self)
        self.centerRightSplitter.addWidget(self.rightPanel)
        self.leftCenterSplitter.setSizes([245,755])
        self.centerRightSplitter.setSizes([750, 250])
        #设置全屏显示
        self.setDisplayFullScreen()

    def setDisplayFullScreen(self):
        # 得到桌面控件
        desktop = QApplication.desktop()
        # 得到屏幕可显示尺寸
        self.rect = desktop.availableGeometry()
        # 获取标题栏高度
        titleBar = self.style().pixelMetric(QStyle.PM_TitleBarHeight)
        # 设置窗口尺寸
        self.setGeometry(self.rect.x(), self.rect.y(),
                         self.rect.width(), self.rect.height() - titleBar)
        self.move(0,0)#把窗口移动到（0,0）坐标

    def closeEvent(self, e):
        print("我隐藏了")
        self.hide()
